package com.unitd.frame.mybatis.plugin.pagination.comm;

import java.util.List;

/**
 * @desc 自定义的分页对象信息类,用于分页处理
 * @filename Page.java
 * @copyright www.unitd.com
 * @author Hudan
 * @version 1.0
 * @date 2017/2/5
 */
public class Page<T> extends PageParams {

	/** 总记录数 */
	private long total;
	/** 总页数 */
	private int pages;
	/** 结果集 */
	private List<T> data;

	public Page() {
	}

	/**
	 * @desc 构造方法,实现分页逻辑处理
	 * @param pageParams 分页参数信息
	 * @param total 总记录条数
	 * @param data 结果集
	 */
	public Page(PageParams pageParams, long total, List<T> data) {
		setPageNo(pageParams.getPageNo());
		setPageSize(pageParams.getPageSize());
		this.total = total;
		this.data = data;
		this.pages = (int) ((this.total / this.getPageSize()) + (this.total % this.getPageSize() == 0 ? 0 : 1));
	}


	public long getTotal() {
		return total;
	}

	public void setTotal(long total) {
		this.total = total;
	}

	public int getPages() {
		return pages;
	}

	public void setPages(int pages) {
		this.pages = pages;
	}

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}
}